package com.jy.api.domain;

import com.thoughtworks.xstream.annotations.XStreamAlias;
import lombok.Data;
import lombok.ToString;
import org.apache.commons.lang3.StringUtils;

/**
 * Created by hanxi on 2018/8/29.
 */
@Data
@XStreamAlias("xml")
@ToString
public class SwiftPassPaymentNotify {
    @XStreamAlias("version")
    private String version;

    @XStreamAlias("charset")
    private String charset;

    @XStreamAlias("sign_type")
    private String signType;

    @XStreamAlias("status")
    private String status;

    @XStreamAlias("message")
    private String message;

    @XStreamAlias("result_code")
    private String resultCode;

    @XStreamAlias("mch_id")
    private String mchId;

    @XStreamAlias("device_info")
    private String deviceInfo;

    @XStreamAlias("nonce_str")
    private String nonceStr;

    @XStreamAlias("err_code")
    private String errCode;

    @XStreamAlias("err_msg")
    private String errMsg;

    @XStreamAlias("sign")
    private String sign;

    @XStreamAlias("openid")
    private String openId;

    @XStreamAlias("trade_type")
    private String tradeType;

    @XStreamAlias("is_subscribe")
    private String isSubscribe;

    @XStreamAlias("pay_result")
    private String payResult;

    @XStreamAlias("pay_info")
    private String payInfo;

    @XStreamAlias("transaction_id")
    private String transactionId;

    @XStreamAlias("out_transaction_id")
    private String outTransactionId;

    @XStreamAlias("sub_is_subscribe")
    private String subIsSubscribe;

    @XStreamAlias("sub_appid")
    private String subAppId;

    @XStreamAlias("sub_openid")
    private String subOpenId;

    @XStreamAlias("out_trade_no")
    private String outTradeNo;

    @XStreamAlias("total_fee")
    private int totalFee;

    @XStreamAlias("time_end")
    private String timeEnd;

    @XStreamAlias("bank_type")
    private String bankType;

    @XStreamAlias("bank_billno")
    private String bankBillNo;

    public boolean isPaymentSuccess() {
        if (status.equals("0") && StringUtils.isNotEmpty(resultCode) && resultCode.equals("0")) {
            return true;
        } else {
            return false;
        }
    }

}
